<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>{$Think.session.user.p_u_id|get_web_f_mesage}</title>
  <link rel="stylesheet" href="__PUBLIC__/script/jquery-weui/dist/lib/weui.min.css?v=1.0.0">
  <link rel="stylesheet" href="__PUBLIC__/script/jquery-weui/dist/css/jquery-weui.min.css?v=1.0.0">
  <link rel="stylesheet" href="__PUBLIC__/styles/base.css?v=1.0.0">
  <!-- select2库，用于多选下拉 -->
  <link rel="stylesheet" href="__PUBLIC__/script/select2/dist/css/select2.min.css?v=1.0.0" type="text/css" />
  <link rel="stylesheet" href="__PUBLIC__/styles/next_pingu_alt.css?v=1.0.0">

  <script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/jquery"></script>
  <script src="__PUBLIC__/script/pub/qudao_type.js"></script>
  <script src="__PUBLIC__/script/pub/chanpin_type.js"></script>
  <script src="__PUBLIC__/script/common.js" common-data-1="{:U('Mix/dest')}"></script>
  <script src="__PUBLIC__/script/jquery-weui/dist/js/jquery-weui.min.js"></script>
  <script src="__PUBLIC__/script/jquery-weui/dist/js/city-picker.min.js"></script>
  <!-- select2库，用于多选下拉 -->
  <script src="__PUBLIC__/script/select2/dist/js/select2.full.min.js"></script>
  <script src="__PUBLIC__/script/select2/dist/js/i18n/zh-CN.js"></script>
  <!-- 回填 -->
  <script src="__PUBLIC__/script/genDIYForm.js"></script>
</head>
<body inori-xiaolei-id=''>
  <div style='display:none;'>
    <input type="hidden" name="获取自由表单ajax地址" id="get_new_free_form" value = "{:U('Admin/Wxauthorise/biaoqian_ajax')}">
    <form autocomplete="off" action="{:U('WebUser/last_product')}" id='hidden_form_1' method="post"></form>
  </div>
  <div class="container">
    <div class="header">{$Think.session.user.p_u_id|get_web_f_mesage}</div>
    <div class="message_box">
      <div style='height:2vh;'></div>
      <div class="weui_cells">
        <div class="tag_title weui_cell" id='only_title'>银行 - 月供贷</div>
        <hr style="border:none;background-color:#ccc;width:95%;margin:0 auto;margin-bottom:1rem;height:1px;">
      </div>
    </div>
    <div class="DIYForm">
      <div class="placeholder">请耐心等待页面加载</div>
    </div>
    <div style="height:5vh;width:100%;"></div>

    <div class="weui-flex button_container">
      <div class="weui-flex__item"><a href="javascript:void(0);" data-target="#shenhe_popup" class="weui-btn weui-btn_primary open-popup" id='checkForm'>下一步</a></div>
      <div class="weui-flex__item"><a href="javascript:void(0);" class="weui-btn weui-btn_warn" onclick="fall_back(this, event)">返回</a></div>
    </div>
  </div>
  <div id="shenhe_popup" class="weui-popup__container">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
      <h1 class="title close-popup">选择协助你的按揭员</h1>
      <div class="weui-grids">
        <volist name='web_user_list' id='web_user'>
        <div href="javascript:void(0)" onclick="postThis(this, event)" class="weui-grid js_grid" inori-data='{$web_user.web_id}'>
          <div class="weui-grid__icon">
            <if condition="$web_user['web_img']"><img src="{$web_user['web_img']}" alt="u900"><else /><img src="__PUBLIC__/res/u900.png" alt="u900"></if>
          </div>
          <div class="weui-grid__label">
            {$web_user.web_name}
            <div class="tel_box"><a href="tel:{$web_user.web_phone};">{$web_user.web_phone}</a></div>
          </div>
        </div>
        </volist>
      </div>
    </div>
  </div>
  <!-- submit function -->
  <script>
    // * 8=>array(
    // *      0 =>array(
    // *         0=>'小类id',
    // *         1=>array(
    // *           'fromdata' =>
    // *               array(
    // *                  0=>array(
    // *                    'md_id' =>13,
    // *                    'input_type' =>1,
    // *                    'm_group' =>'155_0',
    // *                    'maindata' =>123,
    // *                    'altdata' =>'小于等于',
    // *                    'bq_id' =>'小类id',
    // *                  )
    // *               )
    // *           )
    // *       )
    // *    )
    function postThis (_this, evt) {
      $("[name^='[main_data]']").each((index, item) => {
        if ($(item).val() === '') {
          evt.preventDefault()
          $.closePopup()
          $.toptip('请先填写完整表单', 'error')
          throw new Error('请先填写完整表单')
          return false
        }
      })
      if (String(evt.target).indexOf('tel:') === -1) {
        let shen_name = $(evt.target).closest('.js_grid').attr('inori-data')
        const tempInput = `<input type="radio" name="shen_name" value='${shen_name}' form='hidden_form_1'>`
        sessionStorage.setItem('shenheName', `${shen_name}`)
        $('#hidden_form_1').append(tempInput)
        /* 储存本页数据 */
        // let wholeFormValue = sessionStorage.getItem('rawFormData')
        let wholeFormValue = `["1","2"]`
        // wholeFormValue = JSON.parse(wholeFormValue)
        let sessionValue = $('#hidden_form_1').serializeArray()
        wholeFormValue = wholeFormValue.concat(sessionValue)
        sessionStorage.setItem('rawFormData', JSON.stringify(wholeFormValue))
        sessionStorage.setItem('rawFormData_3', JSON.stringify(sessionValue))
        /* end 储存本页数据 */
        // throw new Error('debugging')
        let formName = genNewForm('postBtn')
        sessionStorage.setItem('nextPingu', JSON.stringify($(`#${formName}`).serializeArray()))
        $.closePopup()
        // 即将提交提示
        $.toptip('即将提交输入信息，请稍后', 'success')
        setTimeout(function(){
          $(`#${formName}`).submit()
        }, 0)
      }
    }
    $('.weui-popup__modal').on('click', function (evt) {
      if ($(evt.target).hasClass('weui-popup__modal')) {
        $.closePopup()
      }
    })
  </script>
  <script id="fallBackScript">
    /* 返回上一页 */
    function fall_back (_this, evt) {
      location.href=`{:U('WebUser/new_pingu')}`
    }
  </script>
  <script>
    $(document).ready(() => {
      $('#checkForm').on('click', (evt) => {
        $("[name^='[main_data]']").each((index, item) => {
          if ($(item).val() === '') {
            evt.preventDefault()
            evt.stopPropagation()
            $.toptip('请先填写完整表单', 'error')
            $.closePopup()
            throw new Error('请先填写完整表单')
            return false
          }
        })
      })
      if (sessionStorage.getItem('nextAlt')) {
        $(`#only_title`).text(sessionStorage.getItem('nextAlt'))
      }
    })
  </script>
</body>
</html>
